package ch06.staticInnerClass;

public class StaticInnerClassTest {

	public static void main(String[] args) {
		double[] d = new double[20];
		for (int i  = 0; i < d.length; i++) {
			d[i] = 100* Math.random();
		} 
		ArrayAlg.Pair p = ArrayAlg.minmax(d);
		System.out.println("min = " + p.getMin());
		System.out.println("max = " + p.getMax());

	}

}

class ArrayAlg {
	public static class Pair {
		private double min;
		private double max;
		
		public Pair (double p_min, double p_max) {
			min = p_min;
			max = p_max;
		}
		
		public double getMin() {
			return min;
		}
		public double getMax() {
			return max;
		}
	}
	public static Pair minmax(double[] values) {
		double min = Double.MAX_VALUE;
		double max = Double.MIN_VALUE;
		System.out.println("Double.MAX_VALUE: " + Double.MAX_VALUE);
		System.out.println("Double.MIN_VALUE: " + Double.MIN_VALUE);
		
		for (double v : values) {
			if (min > v) min = v;
			if (max < v) max = v;
		}
		
		return new Pair(min, max);
	}
}
